<?php
/**
 * Custom Post Types Registration
 * 
 * @param array $custom_post_type
 * 
 * @author Sam
 * @since Boarding Sports 1.0
 */
function bs_register_custom_post_type( $custom_post_type )
{
  $result = register_post_type( 
        $custom_post_type['post_type'],
        array(
              'labels' => array(
                    'name' => __( $custom_post_type['name'] ),
                    'singular_name' => __( $custom_post_type['singular_name'] ),
                    'add_new' => _x( 'Add New', $custom_post_type['add_new'] ),
                    'add_new_item' => __( $custom_post_type['add_new_item'] ),
                    'edit_item' => __( $custom_post_type['edit_item'] ),
                    'new_item' => __( $custom_post_type['new_item'] ),
                    'view_item' => __( $custom_post_type['view_item'] ),
                    'search_items' => __( $custom_post_type['search_items'] ),
                    'not_found' => __( $custom_post_type['not_found'] ),
                    'not_found_in_trash' => __( $custom_post_type['not_found_in_trash'] )
              ),
              'public' => $custom_post_type['public'],
							'publicly_queryable' => $custom_post_type['publicly_queryable'],
							'exclude_from_search' => $custom_post_type['exclude_from_search'],
              'has_archive' => $custom_post_type['has_archive'],
              'hierarchical' => $custom_post_type['hierarchical'],
              'rewrite' => $custom_post_type['rewrite'],
							'query_var' => $custom_post_type['query_var'],
							'show_ui' => $custom_post_type['show_ui'],
							'show_in_nav_menus' => $custom_post_type['show_in_nav_menus'],
              'supports'=> $custom_post_type['supports'],
              'menu_position' => $custom_post_type['menu_position'],
              'taxonomies' => $custom_post_type['taxonomies']
        )
  );
	
	if ( is_admin() && is_wp_error($result) )
		echo 'Error on: ' , $custom_post_type['name'] , ': ' , $result->get_error_message();
}

/*
'supports'=> array(
      'title',
      'editor',
      'author',
      'thumbnail', 
      'excerpt',
      'trackbacks',
      'custom-fields',
      'comments',
      'revisions',
      'post-formats',
      'page-attributes'
),
*/


/**
 * Custom Post Types Definition
 * 
 * @author Sam
 * @since Boarding Sports 1.0
 */
function bs_define_custom_post_types()
{
  $post_types = array(
        'shoes-and-apparel' => array(
              'post_type' => 'shoes and apparel',
              'name' => 'Shoes and Apparel',
              'singular_name' => 'Shoes and Apparel',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'shoes-and-apparel',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array ( 
										'slug' => 'shoes-and-apparel'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Shoes and Apparel',
              'edit_item' => 'Edit Shoes and Apparel',
              'new_item' => 'New Shoes and Apparel',
              'view_item' => 'View Shoes and Apparel',
              'search_items' => 'Search Shoes and Apparel',
              'not_found' => 'No Shoes and Apparel found',
              'not_found_in_trash' => 'No Shoes and Apparel found in trash',
              'menu_position' => 5, 
              'hierarchical' => false,
              'supports' => array( 
                    'title',
                    'editor',
                    'author',
                    'thumbnail', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments',
                    'revisions'
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
        'boards-accessories' => array(
              'post_type' => 'boards-accessories',
              'name' => 'Boards and Accessories',
              'singular_name' => 'Boards and Accessories',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'boards-accessories',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'boards-accessories'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Boards and Accessories',
              'edit_item' => 'Edit Boards and Accessories',
              'new_item' => 'New Boards and Accessories',
              'view_item' => 'View Boards and Accessories',
              'search_items' => 'Search Boards and Accessories',
              'not_found' => 'No Boards and Accessories found',
              'not_found_in_trash' => 'No Boards and Accessories found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'revisions',
										'page-attributes',
										'thumbnail',
										'editor',
										'author', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments'
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
				'shops-partners' => array(
              'post_type' => 'shops-partners',
              'name' => 'Shops / Partners',
              'singular_name' => 'Shops / Partners',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'shops-partners',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'shops-partners'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Shops / Partners',
              'edit_item' => 'Edit Shops / Partners',
              'new_item' => 'New Shops / Partners',
              'view_item' => 'View Shops / Partners',
              'search_items' => 'Search Shops / Partners',
              'not_found' => 'No Shops / Partners found',
              'not_found_in_trash' => 'No Shops / Partners found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'editor',
										'revisions',
										'author',
                    'thumbnail', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments'
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        )
  );
  
  foreach( $post_types as $post_type )
  {
    bs_register_custom_post_type( $post_type );
  }
}

/**
 * Initialization
 * 
 * @author Sam
 * @since Boarding Sports 1.0
 */
function bs_customs_init()
{
  bs_define_custom_post_types();
  //bs_define_custom_taxonomies();
}
add_action( 'init', 'bs_customs_init', 0 );

